/*
 *  WaveTable.cpp
 *  SoundController0002
 *
 *  Created by jiro on 10/11/22.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#include "WaveTable.h"

namespace sc 
{

	WaveTable::WaveTable( Type type, double frequency, double adjuster )
		: type( type ),
		  frequency( frequency ),
		  adjuster( adjuster )
	{}

	WaveTable::~WaveTable()
	{}

	bool WaveTable::operator == ( const WaveTable& rhs ) const
	{
		if ( type == rhs.type &&
			 frequency == rhs.frequency &&
			 adjuster == rhs.adjuster )
		{
			return true;
		}
		return false;
	}

	bool WaveTable::operator != ( const WaveTable& rhs ) const
	{
		return ! ( *this == rhs );
	}
		
	bool WaveTable::operator < ( const WaveTable& rhs ) const 
	{
		bool isEqual;  
		
		isEqual = type == rhs.type;
		if ( ! isEqual ) {
			return type < rhs.type;
		}

		isEqual = frequency == rhs.frequency;
		if ( ! isEqual ) {
			return frequency < rhs.frequency;
		}

		isEqual = adjuster == rhs.adjuster;
		if ( ! isEqual ) {
			return adjuster < rhs.adjuster;
		}
		return false;
	} 

	WaveTable::Type WaveTable::GetType() const
	{
		return type;
	}

	double WaveTable::GetAdjuster() const
	{
		return adjuster;
	}

	double WaveTable::GetFrequency() const
	{
		return frequency;
	}
	
	std::string WaveTable::ToString() const
	{
		std::string s;
		std::stringstream ss;
		s.append( "WaveTable, type: " );

		switch ( type ) {
		case Type_Sine:
			s.append( "sine" );
			break;
		case Type_Constant:
			s.append( "constant" );
			break;
		case Type_Array:
			s.append( "array" );
			break;
		case Type_Function:
			s.append( "function" ); 
			break;
		case Type_Null:
			s.append( "null" );
			break;
		}
		s.append( ", frequency: " );
		ss << frequency;
		s.append( ss.str() );

		s.append( ", adjuster: " );
		ss.str( "" );
		ss << adjuster;
		s.append( ss.str() );

		return s;
	}

}